// ExeRunner.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>

int _tmain(int argc, _TCHAR* argv[])
{
	Wow64RedirectOff scopedRedirect;
	
	if (argc <=1)
		return -1;
	std::wstring str = std::wstring();
	for (int i = 2; i < argc; i++)
	{
		str.append(L" ");
		str.append(argv[i]);
	}

	
	PROCESS_INFORMATION lpProcessInfo = PROCESS_INFORMATION();
	STARTUPINFO startupInfo = STARTUPINFO();
	LPWSTR wText = new WCHAR[str.length() + 1];
	wcscpy_s(wText, str.length() + 1, str.data());
	if (!CreateProcess(argv[1], wText, NULL, NULL, NULL, NULL, NULL, NULL, &startupInfo, &lpProcessInfo))
	{
		return -1;
	}
	
	
	WaitForSingleObject(lpProcessInfo.hProcess, INFINITE);
	DWORD exit;
	
	GetExitCodeProcess(lpProcessInfo.hProcess, &exit);

	return exit;
}

